package cn.south.campus.admin.campus.model.vo;

import cn.south.campus.admin.campus.model.entity.Student;
import cn.south.campus.common.file.service.ImgJsonDeSerializer;
import cn.south.campus.common.file.service.ImgJsonSerializer;
import cn.south.campus.common.model.vo.BaseVO;
import cn.south.campus.common.utils.DateUtil;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 *
 * </p>
 *
 * @author chow
 * @since 2024/11/13 11:26
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class StudentVo extends BaseVO {
    /**
     * 用户id
     */
    private Long userId;

    /**
     * 姓名
     */
    private String name;

    /**
     * 学号
     */
    private String studentNo;

    /**
     * 学院
     */
    private String college;

    /**
     * 专业
     */
    private String major;

    /**
     * 班级
     */
    private String classes;

    /**
     * 学生证图片
     */
    @JsonSerialize(using = ImgJsonSerializer.class)
    @JsonDeserialize(using = ImgJsonDeSerializer.class)
    private String pic;

    /**
     * 认证状态，0未认证，1已认证，2认证失败
     */
    private Integer status;

    public static StudentVo convert(Student student) {
        if (student == null) {
            return null;
        }
        StudentVo studentVo = new StudentVo();
        studentVo.setId(student.getId());
        studentVo.setUserId(student.getUserId());
        studentVo.setName(student.getName());
        studentVo.setStudentNo(student.getStudentNo());
        studentVo.setCollege(student.getCollege());
        studentVo.setMajor(student.getMajor());
        studentVo.setClasses(student.getClasses());
        studentVo.setPic(student.getPic());
        studentVo.setStatus(student.getStatus());
        studentVo.setCreateTime(DateUtil.format(student.getCreateTime()));
        studentVo.setUpdateTime(DateUtil.format(student.getUpdateTime()));
        return studentVo;
    }
}
